package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper {




    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteSetmealDish(Long id);

    @Insert("insert into setmeal_dish(setmeal_id,dish_id,name,copies,price) values(#{setmealId},#{dishId},#{name},#{copies},#{price})")
    void addSetmealDish(SetmealDish setmealDish);

    List<SetmealVO> selectByPage(SetmealPageQueryDTO setmealPage);

    @AutoFill(OperationType.UPDATE)
    @Update("update setmeal set status = #{status},update_user=#{updateUser},update_time=#{updateTime} where id = #{id}")
    void setmealStartOrStop(Setmeal setmeal);

    @Delete("delete from setmeal where id = #{id}")
    void deleteSetmeal(Long id);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into setmeal(category_id,name,price,status,description,image,update_time,create_time,create_user,update_user) values(#{categoryId},#{name},#{price},#{status},#{description},#{image},#{updateTime},#{createTime},#{createUser},#{updateUser})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void addSetmeal(Setmeal setmeal);



    @Select("select * from setmeal where id = #{id}")
    Setmeal selectSetmealById(Long id);

    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> selectSetmealDishById(Long id);


    @Select("select status from setmeal where id = #{id}")
    Integer selectStatus(Long id);

    @Select("select dish_id from setmeal_dish where setmeal_id = #{id}")
    List<Integer> selectDishIDById(Long id);

    @Select("select status from dish where id = #{id}")
    Integer selectDishStatus(Integer integer);
}
